import { getDepartmentApi } from "@/api/client/configCenter/accountManagement";
import { reactive, ref } from "vue";

export default function InitHook() {
  const formState = reactive<Partial<ClientAccountManagement.AddCustomerForm>>({
    name: undefined,
    accountName: undefined,
    phone: undefined,
    deptId: undefined,
    remark: undefined,
    dataScope: undefined,
    status: 1,
    password: undefined,
    child: []
  });
  const loading = ref<boolean>(false);
  const formDataRef = ref<any>(null);
  const tableRef = ref<any>(null);
  const departmentOpts = ref<Array<Base.GeneraDataType>>([]);
  const getDepartmentOpts = () => {
    return getDepartmentApi({ pageNum: 1, pageSize: 999999 }).then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        departmentOpts.value = data.records || [];
      }
    });
  };
  return {
    formState,
    formDataRef,
    tableRef,
    loading,
    departmentOpts,
    getDepartmentOpts
  };
}
